<template>
	<view class="home_act">
		<view class="content">
			<view class="title" @click="goToPage('/pages/actCenter/actCenter')">
				<text>活动中心</text>
				<view class="arrow">
					<text>更多</text>
					<image src="https://hetp.hephp.cn/static/images/arrow.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="act_wrap">
				<view class="act_item" v-for="(item,index) in actList.slice(0,2)" :key="index" @click="goToPage('/pages/actAdd/actAdd?id='+item.eventId)">
					<view class="img">
						<image :src="item.images" mode="aspectFill"></image>
					</view>
					<view class="act_info">
						<view class="act_name no-wrap">
							<text>{{item.eventName}}</text>
						</view>
						<view class="act_pri">
							<text>¥{{item.eventPrice}}</text>
							<text :class="['state',{'active': item.status==1}]">{{item.status==1?'开启活动':'活动结束'}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getActList } from '@/request/api.js'
	export default {
		data() {
			return {
				actList: []
			};
		},
		created(){
			this.getActList();
		},
		mounted() {},
		methods: {
			async getActList(){
				let res = await getActList({limit:2});
				console.log(res.data)
				this.actList = res.data
			}
		},
	}
</script>

<style lang="scss" scoped>
.content {
	background-color: #fff;
	border-radius: 14rpx;
	.title {
		padding: 40rpx 25rpx 25rpx;
		border-bottom: 1px solid $line-grey;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.arrow {
			display: flex;
			align-items: center;
			text {
				color: $text-grey;
				font-size: 28rpx;
			}
			image {
				width: 40rpx;
			}
		}
	}
	.act_wrap {
		width: 100%;
		box-sizing: border-box;
		padding: 25rpx 20rpx;
		.act_item {
			box-sizing: border-box;
			width: 100%;
			height: 150.36rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			background-color: $ligth-grey;
			padding: 20rpx;
			&:nth-child(n+2){
				margin-top: 30rpx;
			}
			.img {
				margin-right: 30rpx;
				flex-shrink: 0;
				image {
					width: 120rpx;
					height: 120rpx;
				}
			}
			.act_info {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-around;
			}
			.act_name {
				font-weight: bold;
				font-size: 29rpx;
				line-height: 45rpx;
				margin-bottom: 20rpx;
			}
			.act_pri {
				font-size: 29rpx;
				font-weight: 400;
				color: #3D3D3D;
				line-height: 45rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.state {
					font-size: 22rpx;
					padding: 0 8rpx;
					background-color: $bg-grey;
					color: #3D3D3D;
					line-height: 45rpx;
					&.active {
						background-color: #e2eafe;
						color: $uni-primary;
					}
				}
			}
		}
	}
}
</style>
